﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.Networking.Connectivity;

namespace Atletika.Helpers
{
    public static class ConnectionHelper
    {
        public static bool ConnectedToInternet()
        {
            ConnectionProfile InternetConnectionProfile = NetworkInformation.GetInternetConnectionProfile();

            if (InternetConnectionProfile == null)
            {
                return false;
            }

            var level = InternetConnectionProfile.GetNetworkConnectivityLevel();

            return level == NetworkConnectivityLevel.InternetAccess;
        }

        public static async void LaunchUri(string siteAddress)
        {
            try
            {
                Uri uri = new Uri(siteAddress);
                var launched = await Windows.System.Launcher.LaunchUriAsync(uri);
            }
            catch
            {
                //handle the exception
            }
        }
    }
}
